<script src="menu.js" type="text/javascript"></script>
<script type="text/javascript">
    function initMenu() {
    $('#menu ul').hide();
    <?php if (isset($type) && isset($category)) {
            if ($type == 'active') { ?>
                $('#menu ul:last').show();
                $('#<?php echo $type.$category?>').animate( {
                    paddingLeft:"30px"
                } );
    <?php   }
            elseif ($type == 'inactive') { ?>
                $('#menu ul:first').show();
                $('#<?php echo $type.$category?>').animate( {
                    paddingLeft:"30px"
                } );
    <?php   }
    } ?>
    $('#menu li a').click(
    function() {
    var checkElement = $(this).next();
    if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
    return false;
    }
   if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
   $('#menu ul:visible').slideUp('normal');
   checkElement.slideDown('normal');
   return false;
   }
   }
   );
   }
   $(document).ready(function() {initMenu();});
</script>
<?php
$users=false;
$categories=false;
$advert=false;
if(isset($active_link)) {
    switch ($active_link) {
        case 'listusers':
        case 'adduser':
        case 'edituser':
            $users=true;
            break;
        case 'listcategories':
        case 'addcategory':
        case 'editcategory':
            $categories=true;
            break;
        case 'listadvertisments':
        case 'addadvertisment':
        case 'editadvertisment':
        case 'advertismentperpage':
            $advert=true;
            break;
    }
}

?>
<div class="leftspaceAdmin">
    <ul id="menu">
        <li>
            <a href="<?php echo base_url()."panelforadmin/listusers";?>" class="<?php echo $users?"selected":"";?>">Users</a>
        </li>
        <li>
            <a href="<?php echo base_url()."panelforadmin/publishads";?>">Inactive Ads</a>
            <ul>
                <li id ="inactiveall"><a href="<?php echo base_url()."panelforadmin/publishads/inactive/all";?>">All Categories</a></li>
                <?php foreach ($all_categories as $key=>$category) {
                   echo '<li id = "inactive'.$category->cat_id.'"><a href="'.base_url().'panelforadmin/publishads/inactive/'.$category->cat_id.'">'.$category->cat_name.'</a></li>';
                }?>
            </ul>
        </li>
        <li>
            <a href="<?php echo base_url()."panelforadmin/publishads";?>">Active Ads</a>
            <ul>
                <li id ="activeall"><a href="<?php echo base_url()."panelforadmin/publishads/active/all";?>">All Categories</a></li>
                <?php foreach ($all_categories as $key=>$category) {
                   echo '<li id = "active'.$category->cat_id.'"><a href="'.base_url().'panelforadmin/publishads/active/'.$category->cat_id.'">'.$category->cat_name.'</a></li>';
                }?>
            </ul>
        </li>
        <li>
            <a href="<?php echo base_url()."panelforadmin/listcategories";?>" class="<?php echo $categories?"selected":"";?>">Categories</a>
        </li>
        <li class="last">
            <a href="<?php echo base_url()."panelforadmin/listadvertisments";?>" class="<?php echo $advert?"selected":"";?>">Advertisment</a>
        </li>
    </ul>
    <div class="cleardiv"></div>
</div>
